package com.zuihai.app.mvp.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.jess.arms.utils.KnifeUtil;
import com.zuihai.app.R;
import com.zuihai.app.mvp.ui.widget.GifView;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/5/20 0020.
 */

public class LoadingDialog extends Dialog {

    @BindView(R.id.iv_loading)
    GifView mLoadingView;

    @BindView(R.id.tv_content)
    TextView tvContent;
    public LoadingDialog(@NonNull Context context) {
        this(context, R.style.centerDialog);
    }

    private LoadingDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        KnifeUtil.bindTarget(this, this);
        initWindow();
    }


    /**
     * 初始化窗口信息
     */
    private void initWindow() {
        //设置dialog点击外部不消失
        setCanceledOnTouchOutside(false);
        Window window = getWindow();
        //设置dialog在屏幕底部
        window.setGravity(Gravity.CENTER);
        //获得window窗口的属性
        WindowManager.LayoutParams lp = window.getAttributes();
        //设置窗口宽度为充满全屏
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        //设置窗口高度为包裹内容
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //将设置好的属性set回去
        window.setAttributes(lp);
    }
}
